package cn.spring.demo2;

import org.apache.log4j.Logger;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;

/**
 * xml配置声明式事务管理
 */
public class AccountServiceImpl implements AccountService {
	private static Logger logger = Logger.getLogger(AccountServiceImpl.class);
	
	// 注入DAO
	private AccountDao accountDao;
	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}
	
	@Override
	public void transfer(String out, String in, Double money) {
	
		accountDao.outMoney(out, money);
		logger.info(out + "转出" + money);
		int i = 1 / 0;
		accountDao.inMoney(in, money);
		logger.info(in + "转入" + money);				

	}
	
}
